package utilidades;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;

public class LerArquivo {

	public static Collection ler(String arquivo) throws IOException {
		Collection<String> alist = new ArrayList<String>();
		int i=0;
		try {
			//abre o arquivo numa stream 
			FileInputStream streamin = new FileInputStream(arquivo);
			//converte bytes em caracteres 
			InputStreamReader streamreader = new InputStreamReader(streamin);
			//cria um buffer para acesso mais rapido ao arquivo
			BufferedReader bwreader = new BufferedReader(streamreader);
			String line = null;
			while(bwreader.ready()) {
				line=bwreader.readLine();
				i++;
				if (!line.equals("")) { 
					alist.add(line);
				}
			}
			bwreader.close();
			streamreader.close();
			streamin.close();
		}catch (Exception e) {
                    e.printStackTrace();
		}		 
		return  alist;
	}
}
